package com.lyb.services.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lyb.Dto.CategoryDto;
import com.lyb.mapper.CategoryMapper;
import com.lyb.pojo.Category;
import com.lyb.services.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategoryServiceImpl implements CategoryService {
    @Autowired
    CategoryMapper categoryMapper;
    @Override
    public Boolean add(CategoryDto category) {
        return categoryMapper.add(category);
    }

    @Override
    public Boolean del(Long id) {
        return categoryMapper.del(id);
    }

    @Override
    public Boolean update(Category category) {
        return categoryMapper.update(category);
    }

    @Override
    public PageInfo<Category> queryPage(Integer pageSize, Integer pageNum) {
        PageHelper.startPage(pageNum,pageSize);
        List<Category> res = categoryMapper.queryPage();
        PageInfo<Category> pres = new PageInfo<>(res);
        return pres;
    }
}
